/********************************************************************
  Mega Mario SRC
    created:	2005/09/18
	created:	18:9:2005   10:13
	author:		Jens Wellmann (c)
*********************************************************************/



#include "Global.h"
#include "unixutils.h"



SDL_Surface *screen;
SDL_Window *screenWindow;
SDL_Renderer *renderer;
SDL_Surface *helpscreen;
SDL_Surface *cheatscreen;

SDL_Event event;

Uint8 *keys;

char* cheatcode;

bool HighQualityMusic_available=0;

bool Real_Fullscreen;

 int WIDTH = 1024,GL_Width=1024;
 int HEIGHT = 768,GL_Height=768;

 ofstream out_logfile;
 

double frame_multi;

#ifndef __unix__
bool NoFrameCheck = 0;
#endif
bool gameStarted = 0,gameStartedVirtual = 0,pixelation=1,show_blood = 0,cheater=0,cheats_enabled=0;
int nosound = 1;

Uint32 magenta;
int cam_x=50,cam_y=3200,bonus_activ=0;

Mix_Chunk *SOUND[MAX_SOUNDS];
s_music_archive MusicArchive;

int musicvolume=MIX_MAX_VOLUME,soundvolume;

SDL_Color HUDColor;
SDL_Color HUDColorbg;
TTF_Font* font;

int GOOMBAcount;
cGoomba* GOOMBA[MAXENEMY];
int GOOMBABIGcount;
cGoombaBig *GOOMBABIG[5];
int TURTLEFLYcount;
cTurtleFly *TURTLEFLY[MAXENEMY];
int SPINYcount;
cSpiny *SPINY[MAXENEMY];
int FIRECIRCLEcount;
cFireCircle *FIRECIRCLE[MAXENEMY];
int CANNONcount;
cCannon *CANNON[MAXENEMY];
int BRETTcount;
cBrett *BRETT[MAXENEMY];

cScene *LEVEL;
cPlayer *PLAYER;
cBonus* BONUS_DYNAMIC[5];
cBlood *BLOOD_GENERATOR;

cGamepad *Gamepad;
HUD_STRUCT HUD;

void unloadGlobalSprites()
{
	for(int i=1;i<MAX_BONUS_TEXTURES;i++)
		SDL_FreeSurface(LEVEL->Bonus_Textures[i]);
	SDL_FreeSurface(screen);
}

void instruct(char* path)
{
	bool READY=0;
	SDL_Surface* sch = LoadIMG(path);
	SDL_UpperBlit(sch,0,screen,0);
	drawGLscreen();
	SDL_BlitSurface(sch,0,screen,0);
	SDL_UpdateWindowSurface(screenWindow);
	drawGLscreen();
	SDL_Delay(2000);
	SDL_Event MegaEvent;
	while(!READY)
	{
		while(SDL_PollEvent(&MegaEvent))
		{
			switch(MegaEvent.type)
			{
			case SDL_KEYDOWN:
				READY=1;
				break;					
			}			
		}
	}
	SDL_FreeSurface(sch);
}